﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SoufunData
{
    public class ConfigClass
    {

        public static void SaveImageDownloadUrl(string imgUrl)
        {
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");
            myini.WriteString("SYSTEMCONFIG", "DownloadImageUrl", imgUrl);

        }
         
        public static string ReadImageDownLoadUrl()
        {
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");
            string url = myini.ReadString("SYSTEMCONFIG", "DownloadImageUrl", "http://www.cityofcar.com:8086/SouFun/");
            if (url == "http://www.cityofcar.com:8086/SouFun/")
            {
                SaveImageDownloadUrl(url);
            }
            return url;
        }

        public static void SaveFtpConfig(string host,string userName,string password)
        {
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");
            myini.WriteString("SYSTEMCONFIG", "FtpHost",host);
            myini.WriteString("SYSTEMCONFIG", "FtpUserName", userName);
            myini.WriteString("SYSTEMCONFIG", "FtpPassword", password);

        }

        public static string[] GetFtpConfig()
        {
            string[] config = new string[3];
            IniFiles myini = new IniFiles(System.Environment.CurrentDirectory + "\\system.ini");
            config[0] = myini.ReadString("SYSTEMCONFIG", "FtpHost", "219.140.165.6");
            config[1] = myini.ReadString("SYSTEMCONFIG", "FtpUserName", "test");
            config[2] = myini.ReadString("SYSTEMCONFIG", "FtpPassword", "123456");
            if (config[0] == "219.140.165.6"
                && config[1]=="test" && config[2]=="123456")
            {
                SaveFtpConfig(config[0],config[1],config[2]);
            }
            return config;
        }


    }
}
